// let toast:Toast = new Toast("此功能暂未开放");
// this.addChild(toast);
class Toast extends egret.Sprite{
    private _tx:egret.TextField = new egret.TextField;
    private _tx2:egret.TextField = new egret.TextField;
    constructor (){
        super();
        let img:eui.Image = new eui.Image();
        img.width = 532;
        img.height = 134;
        img.source = "toast_bg_png";
        this.addChild(img);
        
        // tx.multiline = true;
        this._tx.size = 28;
        this._tx.bold = true;
        this._tx.textColor = 0x2b404f;
        // tx.stroke = 2;
        // tx.strokeColor = 0;
        this._tx.width = 524;
        this._tx.wordWrap = true;
        this._tx.text = "";
        this._tx.fontFamily = "微软雅黑";
        this._tx.textAlign = egret.HorizontalAlign.CENTER;
        // tx.height = 134;
        this._tx.y = 28;
        this.addChild( this._tx );

        this._tx2.size = 30;
        this._tx2.bold = true;
        this._tx2.textColor = 0x333333;
        this._tx2.width = 524;
        this._tx2.wordWrap = true;
        this._tx2.text = "";
        this._tx2.fontFamily = "微软雅黑";
        this._tx2.textAlign = egret.HorizontalAlign.CENTER;
        this._tx2.y = 60;
        this.addChild( this._tx2 );

        this.x = 109;
        this.y = 442;
    }
    public show(msg):void{
        let arr = msg.split("/n");
        if(arr.length > 1){
            this._tx.text = arr[0];
            this._tx2.text = arr[1];
        }else{
            this._tx.text = msg;
            this._tx2.text = "";
        }
        egret.Tween.get( this )
            .to( { alpha: 1.0 }, 200, egret.Ease.quintOut )
            .wait(1000)
            .to( { alpha: 0 }, 200, egret.Ease.quintIn  ).call( ()=>{      /*  y: this.y - 50, */
                if( this.parent ){
                    this.parent.removeChild( this );
                }
        } );
    }
}